home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmLoader
- BackColor = &H00FFFFFF&
- BorderStyle = 3 'Fixed Double
- ClientHeight = 1740
- ClientLeft = 1935
- ClientTop = 2820
- ClientWidth = 5010
- ControlBox = 0 'False
- Height = 2145
- Left = 1875
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- Picture = LOADER.FRX:0000
- ScaleHeight = 1740
- ScaleWidth = 5010
- Top = 2475
- Width = 5130
- Begin PictureBox picFloodBar
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- FillStyle = 2 'Horizontal Line
- Height = 315
- Left = 180
- ScaleHeight = 315
- ScaleWidth = 4590
- TabIndex = 0
- Top = 750
- Width = 4590
- End
- Begin Label labModule
- BackStyle = 0 'Transparent
- Height = 255
- Left = 1860
- TabIndex = 1
- Top = 1200
- Width = 2970
- End
- Option Explicit
- ' ===========================================================================================
- ' Local String Declarations
- ' ===========================================================================================
- Dim sLoaderList As String ' String Declaring the path and list of files to load into memory
- Dim sModuleList() As String ' String Declaring the modules to be loaded into memory
- ' ===========================================================================================
- ' Local Integer Declarations
- ' ===========================================================================================
- Dim iModuleListFileHandler As Integer ' Integer declaring the file handle for the Module list
- Dim iLogFileHandle As Integer
- Dim iProgramState As Integer
- ' ===========================================================================================
- ' Local Long Declarations
- ' ===========================================================================================
- Dim lCurrentPercent As Long ' Current Percentage value for panel
- Dim lMaxPercent As Long ' Maximum percentage value for panel
- ' ===========================================================================================
- ' Local Boolean Declarations
- ' ===========================================================================================
- Dim bDebugMode As Integer
- ' ===========================================================================================
- ' Local Constant Declarations
- ' ===========================================================================================
- Const APPLICATION_INIFILE = "\LOADER.INI" ' Name of the applications INI file
- Const APPLICATION_LOG_FILE = "\LOADER.LOG"
- Sub AppendToReport (sReportString As String)
- ' 950816 sb
- On Error GoTo AppendToReportError
- Print #iLogFileHandle, sReportString
- Exit Sub
- AppendToReportError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "AppendToReport")
- Exit Sub
- Resume 0
- End Sub
- Sub CloseLogFile ()
- On Error GoTo CLoseLogFileError
- Call AppendToReport("=========================================================")
- Call AppendToReport("Loader Stopped " & Format$(Now))
- Call AppendToReport("=========================================================")
- Close #iLogFileHandle
- Exit Sub
- CLoseLogFileError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "CloseLogFile")
- Exit Sub
- Resume 0
- End Sub
- Sub ExitApplication ()
- On Error GoTo ExitApplicationError
- screen.MousePointer = DEFAULT
- End
- Exit Sub
- ExitApplicationError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "ExitApplicationError")
- Exit Sub
- Resume 0
- End Sub
- Sub Form_Load ()
- On Error GoTo Form_LoadError
- screen.MousePointer = HOURGLASS
- Call CentreMe(Me)
- Call SetupGlobalVariables
- Call SetupApplicationVariables
- If bDebugMode Then
- Me.Show
- End If
- Call OpenLogFile
- Call LoadStarterApps
- Call LoadModuleList
- Call CloseLogFile
- Call ExitApplication
- screen.MousePointer = DEFAULT
- Exit Sub
- Form_LoadError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "Form_Load")
- Exit Sub
- Resume 0
- End Sub
- Sub IncreasePercentage ()
- On Error GoTo IncreasePercentageError
- Dim sPercentage As String
- lCurrentPercent = lCurrentPercent + 1
- If Int((lCurrentPercent / lMaxPercent) * 100) <> Int((lCurrentPercent - 1 / lMaxPercent) * 100) Then
- picFloodBar.Cls
- picFloodBar.Line (0, 0)-((Int((lCurrentPercent / lMaxPercent) * 100) * (picFloodBar.ScaleWidth / 100)), picFloodBar.ScaleHeight), QBColor(1), BF
-
- sPercentage = Format$(CLng(Int((lCurrentPercent / lMaxPercent) * 100))) + "%"
- picFloodBar.CurrentX = (picFloodBar.Width - picFloodBar.TextWidth(sPercentage)) \ 2
- picFloodBar.CurrentY = (picFloodBar.Height - picFloodBar.TextHeight(sPercentage)) \ 2
- picFloodBar.Print sPercentage
- End If
- DoEvents
- Exit Sub
- IncreasePercentageError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "IncreasePercentage")
- Exit Sub
- Resume 0
- End Sub
- Function lModuleCount () As Long
- On Error GoTo lModuleCountError
- Dim sModule As String
- Dim lModuleTempCount As Long
- lModuleCount = 0
- While Not EOF(iModuleListFileHandler)
- Line Input #iModuleListFileHandler, sModule
- lModuleTempCount = lModuleTempCount + 1
- ReDim Preserve sModuleList(lModuleTempCount)
- sModuleList(lModuleTempCount) = sModule
- DoEvents
- lModuleCount = lModuleTempCount
- Exit Function
- lModuleCountError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "lModuleCount")
- Exit Function
- Resume 0
- End Function
- Sub LoadMemory (sFileName As String)
- On Error GoTo bLoadMemoryError
- Dim iModuleHandler As Integer
- Dim iRetValue As Integer
- Dim sModuleFileName As String * 100
- Dim bAlreadyInMemory As Integer
- iModuleHandler = GetModuleHandle(sFileName)
- If iModuleHandler <> 0 Then
- iRetValue = GetModuleFileName(iModuleHandler, sModuleFileName, Len(sModuleFileName))
- Call AppendToReport("Module Already Loaded In Memory as " & Trim$(sModuleFileName))
- bAlreadyInMemory = True
- End If
- If Right$(sFileName, 3) = "EXE" Then
- Call LoadProgram(sFileName)
- Else
- If LoadLibrary(sFileName) < 32 Then
- Call AppendToReport("Failed To Load Module " & sFileName)
- Else
- If Not bAlreadyInMemory Then
- Call AppendToReport("Sucessfully Loaded Module " & sFileName)
- End If
- End If
- End If
- Exit Sub
- bLoadMemoryError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "bLoadMemory")
- Exit Sub
- Resume 0
- End Sub
- Sub LoadModuleList ()
- On Error GoTo LoadModuleListError
- Dim sModule As String
- Dim iIndex As Integer
- Call OpenModuleFile
- Call SetPanelPercentage
- Close iModuleListFileHandler
- For iIndex = 1 To lMaxPercent
- If bDebugMode Then labModule.Caption = Trim$(sModuleList(iIndex))
- Call LoadMemory(Trim$(sModuleList(iIndex)))
- If bDebugMode Then Call IncreasePercentage
- Next iIndex
- Exit Sub
- LoadModuleListError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "LoadModuleList")
- Exit Sub
- Resume 0
- End Sub
- Sub LoadProgram (sFileName As String)
- On Error GoTo LoadProgramError
- If WinExec(sFileName, iProgramState) < 32 Then
- Call AppendToReport("Failed To Load Module " & sFileName)
- Else
- Call AppendToReport("Sucessfully Loaded Module " & sFileName)
- End If
- Exit Sub
- LoadProgramError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "LoadProgram")
- Exit Sub
- Resume 0
- End Sub
- Sub LoadStarterApps ()
- On Error GoTo LoadStarterAppsError
- Dim sFileName As String
- Dim iCurrentInputLine As Integer
- iCurrentInputLine = 1
- sFileName = GetINIStringValue("StarterApps", "FileName" & Trim$(Str$(iCurrentInputLine)), "", app.Path & APPLICATION_INIFILE)
- While sFileName <> ""
- ChDir GetINIStringValue("StarterApps", "WorkingDirectory" & Trim$(Str$(iCurrentInputLine)), (app.Path), app.Path & APPLICATION_INIFILE)
- If WinExec(sFileName, Val(GetINIStringValue("StarterApps", "StartState" & Trim$(Str$(iCurrentInputLine)), Str$(SW_SHOWNORMAL), app.Path & APPLICATION_INIFILE))) < 32 Then
- Call AppendToReport("Failed To Load Starter Application " & sFileName)
- Else
- Call AppendToReport("Sucessfully Loaded Starter Applicaton " & sFileName)
- End If
- iCurrentInputLine = iCurrentInputLine + 1
- sFileName = GetINIStringValue("StarterApps", "FileName" & Trim$(Str$(iCurrentInputLine)), "", app.Path & APPLICATION_INIFILE)
- Wend
- ChDir app.Path
- Exit Sub
- LoadStarterAppsError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "LoadStarterApps")
- Exit Sub
- Resume 0
- End Sub
- Sub OpenLogFile ()
- On Error GoTo OpenFileError
- iLogFileHandle = FreeFile
- Open Environ$("WINDIR") & APPLICATION_LOG_FILE For Output As iLogFileHandle
- Call AppendToReport("=========================================================")
- Call AppendToReport("Load Started " & Format$(Now))
- Call AppendToReport("=========================================================")
- Exit Sub
- OpenFileError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "OpenFile")
- Exit Sub
- End Sub
- Sub OpenModuleFile ()
- On Error GoTo OpenModuleFileError
- iModuleListFileHandler = FreeFile
- Open sLoaderList For Input As #iModuleListFileHandler
- Exit Sub
- OpenModuleFileError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "OpenModuleFile")
- Exit Sub
- Resume 0
- End Sub
- Sub SetPanelPercentage ()
- On Error GoTo SetPanelPercentageError
- lCurrentPercent = 0
- lMaxPercent = lModuleCount()
- Exit Sub
- SetPanelPercentageError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "SetPanelPercentage")
- Exit Sub
- Resume 0
- End Sub
- Sub SetupApplicationVariables ()
- On Error GoTo SetupApplicationVariablesError
- sLoaderList = GetINIStringValue("Application", "FileList", app.Path & "\LOADER.TXT", app.Path & APPLICATION_INIFILE)
- bDebugMode = GetINIStringValue("Application", "Debug", "False", app.Path & APPLICATION_INIFILE) = "Yes"
- iProgramState = Val(GetINIStringValue("Application", "StartState", Str$(SW_HIDE), app.Path & APPLICATION_INIFILE))
- Exit Sub
- SetupApplicationVariablesError:
- Call ErrorHandler(Err, Erl, "LOADER.FRM", "SetupApplicationVariables")
- Exit Sub
- Resume 0
- End Sub
-